import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import * as path from "path";
import viteCompression from "vite-plugin-compression";
import { createHtmlPlugin } from "vite-plugin-html";
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import { createStyleImportPlugin } from 'vite-plugin-style-import';



// https://vitejs.dev/config/
export default defineConfig({
	plugins: [
		vue(),
		viteCompression(),
		AutoImport({
			resolvers: [ElementPlusResolver()],
		}),
		Components({
			resolvers: [ElementPlusResolver()],
		}),
		createStyleImportPlugin({
			libs: [
				{
					libraryName: 'element-plus',
					esModule: true,
					resolveStyle: (name) => `element-plus/theme-chalk/${name}.css`,
				},
			],
		}),

	],
	base: './',
	build: {
		outDir: './dist',
	},
	server: {
		host: 'localhost', port: 4000,
		open: false
	},

	resolve: {
		// 配置路径别名
		alias: {
			"@": path.resolve(__dirname, "./src"),
			views: path.resolve(__dirname, './src/views'),
			components: path.resolve(__dirname, './src/components'),
			utils: path.resolve(__dirname, './src/utils'),
			less: path.resolve(__dirname, "./src/less"),
			assets: path.resolve(__dirname, "./src/assets"),
			com: path.resolve(__dirname, "./src/components"),
			store: path.resolve(__dirname, "./src/store"),
			mixins: path.resolve(__dirname, "./src/mixins")
		},
	},


});




